package com.cby.android.sample.adapter.binder

import com.cby.android.sample.R
import com.cby.android.sample.utils.CaiyunUtils
import com.chad.library.adapter.base.binder.QuickItemBinder
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cby.android.sample.bean.caiyun.CaiYunRealtimeBean

/**
 * @description: 当前文档数值
 *
 * @author ChenBaoyang
 * @date 4/27/21 15:02
 */
class WeatherHeaderItemBinder : QuickItemBinder<CaiYunRealtimeBean>() {
    override fun convert(holder: BaseViewHolder, data: CaiYunRealtimeBean) {
        holder.setText(R.id.tv_01, "${data.temperature}°")
        holder.setText(R.id.tv_02, CaiyunUtils.getWeatherText(data.skycon))
        holder.setText(R.id.tv_03, "湿度：${data.humidity * 100}%")
        holder.setText(R.id.tv_04, "体感：${data.apparentTemperature}°")
        holder.setText(
            R.id.tv_05,
            "${CaiyunUtils.getWindDirection(data.wind.direction)} ${CaiyunUtils.getWindScale(data.wind.speed)} 级"
        )
    }

    override fun getLayoutId() = R.layout.item_weather_header
}